/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CCPVArrowDrawerTest.java
 *
 * Created on Dec 6, 2009, 9:30:25 PM
 */
package CCPVConflictArrowDrawer;

import java.awt.Dimension;
import java.awt.Point;
import java.util.Random;

/**
 *
 * @author Evan
 */
public class CCPVArrowDrawerTest extends javax.swing.JApplet
{

  private Point generateRandomPoint()
  {
    int x = randGen.nextInt(defaultSize.width);
    int y = randGen.nextInt(defaultSize.height);

    return new Point(x, y);
  }

  /** Initializes the applet CCPVArrowDrawerTest */
  public void init()
  {
    try
    {
      java.awt.EventQueue.invokeAndWait(new Runnable()
      {

        public void run()
        {
          initComponents();
          arrowD.setSize(defaultSize);
          int lineWidth = randGen.nextInt(15) + 5;
          Point start = generateRandomPoint();
          Point end = generateRandomPoint();
          //int lineWidth = 25;
          //Point end = new Point(50, 100);
          //Point start = new Point(100, 30);
          arrowD.addArrow(start, end, lineWidth);
          arrowD.setupAnimationSteps();
          container.add(arrowD);
          arrowD.startAnimation();
        }
      });
    } catch (Exception ex)
    {
      ex.printStackTrace();
    }
  }

  /** This method is called from within the init() method to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    container = new javax.swing.JPanel();

    container.setBackground(new java.awt.Color(255, 255, 204));

    javax.swing.GroupLayout containerLayout = new javax.swing.GroupLayout(container);
    container.setLayout(containerLayout);
    containerLayout.setHorizontalGroup(
      containerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 710, Short.MAX_VALUE)
    );
    containerLayout.setVerticalGroup(
      containerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 507, Short.MAX_VALUE)
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
  }// </editor-fold>//GEN-END:initComponents
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JPanel container;
  // End of variables declaration//GEN-END:variables
  CCPVArrowDrawer arrowD = new CCPVArrowDrawer();
  Dimension defaultSize = new Dimension(300, 300);
  Random randGen = new Random();
}
